﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CTEM.Controllers.BUS;
using CTEM.Models;
using DevExpress.XtraGrid.Views.Base;

namespace CTEM.ModuleForms.ManageReport
{
    public partial class WorkerSalaryReportChoosed : Form
    {

        private WorkerSalaryBUS _workerSalaryBUS;
        private WorkerBUS _workerBUS;
        private ConstructionBUS _constructionBus;
        private List<CS_ConstructionDTO> _listConstruction;

        private EmployeeBUS _employeeBUS;
        private List<WorkerSalaryDTO> _listWorkerSalary;
        private List<WorkerSalaryDTO> _listSalaryHistory;
        private List<EmployerDTO> _listEmployee;
        private List<WorkerDTO> _listWorker;

        private int row = -1;

        public delegate void WorkerSalaryDelegate(WorkerSalaryDTO workerSalary);
        //declare the event using the delegate
        public event WorkerSalaryDelegate AskInformationChanged;
        public WorkerSalaryReportChoosed()
        {
            InitializeComponent();
            gridView1.BestFitColumns();

            _workerSalaryBUS = new WorkerSalaryBUS();
            _employeeBUS = new EmployeeBUS();
            _workerBUS = new WorkerBUS();
            _listWorkerSalary = new List<WorkerSalaryDTO>();
            _listSalaryHistory = new List<WorkerSalaryDTO>();
            _listEmployee = new List<EmployerDTO>();
            _constructionBus = new ConstructionBUS();
            _listConstruction = new List<CS_ConstructionDTO>();
            LoadWorkerSalary();
        }

      
        public void LoadWorkerSalary()
        {
            _listWorkerSalary = _workerSalaryBUS.LoadAllWks();
            bindingSource1.DataSource = _listWorkerSalary;
        }

        private void BtExport_Click(object sender, EventArgs e)
        {
            var view = sender as ColumnView;
            var workerSalary = gridView1.GetRow(row) as WorkerSalaryDTO;
            if (workerSalary != null)
            {
                AskInformationChanged(workerSalary);
            }
            Hide();
        }
        private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {

            row = e.FocusedRowHandle;
        }
    }
}
